package com.lagou.tomcat;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

import javax.servlet.ServletException;

public class SpringApplication {
    public static  void run(){
        Tomcat tomcat = new Tomcat();
        tomcat.setPort(8091);
        try{
            tomcat.addWebapp("/","D:\\");
            tomcat.start();
            //因为  tomcat.start();是非阻塞型的，所以要阻塞一下，不能让服务停止。
            tomcat.getServer().await();
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (LifecycleException e) {
            e.printStackTrace();
        }
    }
}
